package com.lovo.provider;

import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

public class UserProvider {
    public String selectByQueryProvider(Map<String,Object> map){
        return new SQL(){
            {
                SELECT(
                        "user_id,user_name,user_tel,user_pwd,user_Email"
                );
                FROM("t_user");
                if(map.get("type").equals("用户名")){
                    AND().WHERE("user_name like concat('%',#{content},'%')");
                }
                if(map.get("type").equals("电话号码")){
                    AND().WHERE("user_tel like concat('%',#{content},'%')");
                }
            }
        }.toString();
    }

    public String login(Map<String,Object> map){
        return new SQL(){
            {
                SELECT(
                        "user_id,user_name,user_tel,user_pwd,user_Email"
                );
                FROM("t_user");
                WHERE("user_name = #{userName} and user_pwd = #{userPwd}");
            }
        }.toString();
    }
}
